<div class="js-dashboard-story single-article <%= "single-article-unpublished" unless article.published %> <%= "single-article-archived hidden" if article.archived %>">
  <div class="dashboard-collection-org-details">
    <% if article.organization_id %>
      <span class="dashboard-top-pill"><%= article.organization&.name %></span>
    <% end %>
    <% if article.collection_id %>
      <span class="dashboard-top-pill"><%= t("views.dashboard.article.series_html", series: article.series) %></span>
    <% end %>
  </div>

  <div class="js-ellipsis-menu relative inline-block float-right">
    <button id="ellipsis-menu-trigger-<%= article.id %>" aria-controls="ellipsis-menu-dropdown-<%= article.id %>" aria-expanded="false" aria-haspopup="true" class="crayons-btn crayons-btn--ghost crayons-btn--s crayons-btn--icon">
      <%= crayons_icon_tag("overflow-horizontal", title: t("views.dashboard.article.more.icon")) %>
    </button>

    <div id="ellipsis-menu-dropdown-<%= article.id %>" class="crayons-dropdown top-100 right-0 z-10 align-left js-ellipsis-menu-dropdown">
      <%= form_for(article, method: :patch, remote: true, authenticity_token: true, html: { "data-type": "json", class: "p-0 js-archive-toggle" }) do |f| %>
        <%= f.hidden_field :archived, value: !article.archived %>
        <%= f.hidden_field :from_dashboard, value: 1 %>
        <button type="submit" class="crayons-link crayons-link--block w-100 border-0 bg-transparent">
          <%= t("views.dashboard.article.#{article.archived ? 'unarchive' : 'archive'}") %>
        </button>
      <% end %>
    </div>
  </div>

  <a href="<%= article.current_state_path %>"><h2>
    <%= t("views.dashboard.article.heading.text_html",
          archived: article.archived ? t("views.dashboard.article.heading.archived") : "",
          title: article.title) %>
  </h2></a>
  <div class="dashboard-meta-details">
    <% if article.published %>
      <span>
        <%= t("views.dashboard.article.published_html", date: tag.time(article.readable_publish_date, datetime: article.published_timestamp)) %>
      </span>

      <% if article.edited? %>
        <span>
          · <%= t("views.dashboard.article.edited_html", date: tag.time(article.readable_edit_date, datetime: article.edited_at.utc.iso8601)) %>
        </span>
      <% end %>

      <% article.cached_tag_list_array.each do |tag| %>
        <a href="/t/<%= tag %>"><span class="tag">#<%= tag %></span></a>
      <% end %>
    <% end %>
  </div>
  <div class="dashboard-actions">
    <% if !article.published %>
      <a href="<%= article.current_state_path %>" class="crayons-btn"><%= t("views.dashboard.article.draft") %></a>
    <% end %>
    <a href="<%= article.path %>/edit" class="crayons-btn"><%= t("views.dashboard.article.edit.text") %></a>
    <% if manage_view %>
      <a href="<%= article.path %>/delete_confirm" data-no-instant class="crayons-btn crayons-btn--danger"><%= t("views.dashboard.article.delete") %></a>
      <% if article.profile_pins.any? %>
        <%= form_for(article.profile_pins.first) do |f| %>
          <button class="crayons-btn crayons-btn--secondary"><%= t("views.dashboard.article.unpin") %></button>
        <% end %>
      <% else %>
        <%= form_for(ProfilePin.new) do |f| %>
          <%= f.hidden_field :pinnable_id, value: article.id %>
          <button class="crayons-btn"><%= t("views.dashboard.article.pin.button") %></button>
        <% end %>
      <% end %>
    <% elsif article.published %>
      <a href="<%= article.path %>/manage" class="crayons-btn"><%= t("views.dashboard.article.manage.text") %></a>
    <% elsif @user == article.user %>
      <a href="<%= article.path %>/delete_confirm" data-no-instant class="crayons-btn crayons-btn--danger"><%= t("views.dashboard.article.delete") %></a>
    <% end %>

    <a href="<%= article.path %>/stats" data-no-instant class="crayons-btn"><%= t("views.dashboard.article.stats") %></a>

    <% if discussion_lock %>
      <a href="<%= article.path %>/discussion_unlock_confirm" data-no-instant class="crayons-btn"><%= t("views.dashboard.article.unlock") %></a>
    <% else %>
      <a href="<%= article.path %>/discussion_lock_confirm" data-no-instant class="crayons-btn"><%= t("views.dashboard.article.lock") %></a>
    <% end %>

    <% if article.published %>
      <span id="pageviews-<%= article.id %>" class="crayons-btn dashboard-pageviews-indicator" data-analytics-pageviews data-article-id="<%= article.id %>">
        <span class="page-views-count">
          <% pvs = article.page_views_count %>
          <%= t("views.dashboard.article.views.text_html", count: pvs, scale: tag.span(pvs > 25 ? tag.span(pvs, class: %w[value]) : t("views.dashboard.article.views.u_25"), class: %w[value])) %>
        </span>
        //
        <span class="reactions-count">
          <% prs = article.public_reactions_count %>
          <%= t("views.dashboard.article.reactions.text_html", count: prs, num: tag.span(prs, class: %w[value])) %>
        </span>
        //
        <span class="comments-count">
          <% pcs = article.comments_count %>
          <%= t("views.dashboard.article.comments.text_html", count: pcs, num: tag.span(pcs, class: %w[value])) %>
        </span>
      </span>
    <% end %>
  </div>
  <% if organization && org_admin %>
    <%= form_for(article) do |f| %>
      <%= f.hidden_field :from_dashboard, value: 1 %>
      <input type="hidden" name="destination" value="/dashboard/organization/<%= organization.id %>" />
      <%= t("views.dashboard.article.author_is") %><%= f.select(:user_id, options_for_select(organization.users.pluck(:name, :id), article.user_id)) %>
      <%= f.submit t("views.dashboard.article.submit"), class: "crayons-btn crayons-btn--secondary" %>
    <% end %>
  <% end %>
</div>
<%= javascript_include_tag "dashboardDropdowns", defer: true %>
